﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using YiSha.Util;
using YiSha.Util.Model;
using YiSha.Entity;
using YiSha.Model;
using YiSha.Admin.Web.Controllers;
using YiSha.Entity.SaleManage;
using YiSha.Business.SaleManage;
using YiSha.Model.Param.SaleManage;

namespace YiSha.Admin.Web.Areas.SaleManage.Controllers
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2019-12-04 21:55
    /// 描 述：客户类型控制器类
    /// </summary>
    [Area("SaleManage")]
    public class ClientTypeController :  BaseController
    {
        private ClientTypeBLL clientTypeBLL = new ClientTypeBLL();

        #region 视图功能
        [AuthorizeFilter("sale:clienttype:view")]
        public ActionResult ClientTypeIndex()
        {
            return View();
        }

        public ActionResult ClientTypeForm()
        {
            return View();
        }
        #endregion

        #region 获取数据
        [HttpGet]
        [AuthorizeFilter("sale:clienttype:search")]
        public async Task<ActionResult> GetListJson(ClientTypeListParam param)
        {
            TData<List<ClientTypeEntity>> obj = await clientTypeBLL.GetList(param);
            return Json(obj);
        }

        [HttpGet]
        [AuthorizeFilter("sale:clienttype:search")]
        public async Task<ActionResult> GetPageListJson(ClientTypeListParam param, Pagination pagination)
        {
            TData<List<ClientTypeEntity>> obj = await clientTypeBLL.GetPageList(param, pagination);
            return Json(obj);
        }

        [HttpGet]
        public async Task<ActionResult> GetFormJson(long id)
        {
            TData<ClientTypeEntity> obj = await clientTypeBLL.GetEntity(id);
            return Json(obj);
        }
        #endregion

        #region 提交数据
        [HttpPost]
        [AuthorizeFilter("sale:clienttype:add,sale:clienttype:edit")]
        public async Task<ActionResult> SaveFormJson(ClientTypeEntity entity)
        {
            TData<string> obj = await clientTypeBLL.SaveForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("sale:clienttype:delete")]
        public async Task<ActionResult> DeleteFormJson(string ids)
        {
            TData obj = await clientTypeBLL.DeleteForm(ids);
            return Json(obj);
        }
        #endregion
    }
}
